import requests
import json

# 发送请求并获取响应
response = requests.get('http://localhost:8000/api/communities/')
print(f'响应状态码: {response.status_code}')
print(f'Content-Type: {response.headers.get("Content-Type")}')

# 尝试解析JSON响应
response.encoding = 'utf-8'  # 确保使用UTF-8编码
json_data = response.json()
print(f'响应JSON数据: {json_data}')

# 打印小区名称
print('小区列表:')
for community in json_data['results']:
    print(f'ID: {community["id"]}, 名称: {community["name"]}')